/*
 * @Author: 唉诺
 * @Date: 2021-02-03 18:26:17
 */
import Phaser from 'phaser-ce'

export default class extends Phaser.State {
  init () {
  }

  preload () {
  }
  createBetElement () {
  }
  create () {
    const bg = this.add.tileSprite(0, 112, this.game.width, this.game.height, 'background')
    const ground = this.add.tileSprite(0, this.game.height - 112, this.game.width, 112, 'ground')
    // bg.tileScale.set(1.32)
    // ground.tileScale.set(1.32)
    bg.autoScroll(-20, 0)
    ground.autoScroll(-100, 0)
    const titleGroup = this.add.group()
    titleGroup.position.set(0, 100)

    titleGroup.create(90, 0, 'title')
    const bird = titleGroup.create(this.game.width - 100, 10, 'bird')
    bird.animations.add('fly')
    bird.animations.play('fly', 12, true)
    this.add.tween(titleGroup).to({y: 120}, 1000, null, true, 0, Number.MAX_VALUE, true)
    const btn = this.add.button(this.game.width / 2, this.game.height / 2, 'btn', () => {
      this.state.start('Play')
    })
    btn.anchor.setTo(0.5, 0.5)
  }
}
